package com.yang.designmode.ActionMode.chainResponsibility.arrayList;

import java.util.ArrayList;
import java.util.List;

/**
 * 责任链
 */
public class HandlerChain {
    private List<Handler> handlers = new ArrayList<>();
    public void addHandler(Handler handler) {
        handlers.add(handler);
    }
    public void handle() {
        for (Handler handler : handlers) {
            boolean handled = handler.handle() ;
            if (handled) {
                break;
            }
        }
    }
}
